package org.jeecg.modules.xj.points.mapper;

import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.xj.points.entity.XjPoints;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.data.repository.query.Param;

import java.util.Map;

/**
 * @Description: 积分
 * @Author: jeecg-boot
 * @Date:   2023-08-11
 * @Version: V1.0
 */
public interface XjPointsMapper extends BaseMapper<XjPoints> {

    @Select("SELECT SUM(num) FROM xj_points WHERE belonger=#{userId}")
    double getUserPoints(@Param("userId")String userId);

    @Select("SELECT\n" +
            "\tsu.id,\n" +
            "\tsu.realname,\n" +
            "\tsu.id_card,\n" +
            "\tsu.hujdz,\n" +
            "\t(SELECT sum(num) FROM xj_points where belonger=su.id) as nums ,\n" +
            "\t(SELECT item_text from sys_dict_item where dict_id='3d9a351be3436fbefb1307d4cfb49bf2' and item_value=su.sex) as sex,\n" +
            "\t(SELECT item_text from sys_dict_item where dict_id='1689914866251583489' and item_value=su.utype) as utype,\n" +
            "\t(SELECT item_text from sys_dict_item where dict_id='1689896544323727362' and item_value=su.nation) as nation\n" +
            "FROM\n" +
            "\tsys_user su\n" +
            "\tWHERE su.id=#{userId}")
    Map<String, Object> getUserVillagerById(String userId);
}
